package com.server.controller;

import com.server.pojo.AdminNotifications;
import com.server.pojo.Entries;
import com.server.service.AdminNotificationsService;
import com.server.service.EntriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 管理员通知表 前端控制器
 * </p>
 *
 * @author ckick
 * @since 2025-09-20 09:29:26
 */
@RestController
public class AdminNotificationsController {
    @Autowired
    AdminNotificationsService adminNotificationsService;
    @Autowired
    EntriesService entriesService;
    /**
     * 该方法添加词条通知
     * @param entryId
     * @param status
     */
    boolean systemNotification(Integer entryId,String status){
        Entries entries = entriesService.getById(entryId);
        AdminNotifications adminNotifications = new AdminNotifications();
        adminNotifications.setReceiverId(entries.getPublisherId());
        adminNotifications.setAdminId(1);
        if (status.equals("approved")) {
            adminNotifications.setTitle("你的词条已通过审核");
            adminNotifications.setContent("你发布的「"+entries.getEntryName()+"」词条已通过审核");
        }else {
            adminNotifications.setTitle("你的帖子有违规内容");
            adminNotifications.setContent("你发布的「"+entries.getEntryName()+"」未通过包含广告链接等，请注意合规");
        }
        return adminNotificationsService.save(adminNotifications);
    }
}
